import express from 'express';
import cors from 'cors';
import bodyParser from 'body-parser';
import { createProxyMiddleware } from 'http-proxy-middleware'
import routes from './routes/index.js';

const app = express();
// 配置代理中间件
const proxy = createProxyMiddleware({
  target: 'https://www.toyodiy.com',
  changeOrigin: true,
  pathRewrite: {
    '^/proxy': '',
  },
});

app.use(cors());
app.use(bodyParser.json());

app.use("/", routes);
app.use('/proxy', proxy)


app.listen(18900, () => {
  console.log('Server is running on port 3000');
})